package com.zhuozhou.jdyc.main.base.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.bumptech.glide.Glide;
import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.api.AppSettingHelper;
import com.zhuozhou.jdyc.api.ConstantsHelper;
import com.zhuozhou.jdyc.base.BaseActivity;
import com.zhuozhou.jdyc.base.BaseViewModel;
import com.zhuozhou.jdyc.databinding.ActivityFingerlockBinding;
import com.zhuozhou.jdyc.wight.dialog.FingerDialog;

/**
 * Created by Chuxy on 2020/4/8
 */
public class FingerViewActivity extends BaseActivity<BaseViewModel, ActivityFingerlockBinding> implements FingerDialog.FingerBack {


    @Override
    protected int getLayoutId() {
        return R.layout.activity_fingerlock;
    }

    @Override
    protected boolean hasToolBar() {
        return false;
    }

    @Override
    public String setTitleBar() {
        return null;
    }

    public static void show(Activity context) {
        Intent intent = new Intent(context, FingerViewActivity.class);
        context.startActivityForResult(intent, ConstantsHelper.FINGER_VIEW_ACTIVITY_REQUEST_CODE);
    }

    public static void show(Activity context, Bundle bundle) {
        Intent intent = new Intent(context, FingerViewActivity.class);
        intent.putExtras(bundle);
        context.startActivityForResult(intent, ConstantsHelper.FINGER_VIEW_ACTIVITY_REQUEST_CODE);
    }

    @Override
    public void initView() {
        //String url = UserAccountHelper.getUser().getHeadPortrait() == null ? "" : UserAccountHelper.getUser().getHeadPortrait();
        Glide.with(this).load("http://m.imeitou.com/uploads/allimg/2019021811/dleoo1eexiy.jpg").error(R.mipmap.icon_head_default).into(binding.imageView);
        binding.imageView2.setOnClickListener(v -> {
            FingerDialog fingerDialog = new FingerDialog(this);
            fingerDialog.create();
            fingerDialog.setCallBackListener(this::fingerBack);
        });
    }

    @Override
    public void initData(Bundle bundle) {
        FingerDialog fingerDialog = new FingerDialog(this);
        fingerDialog.create();
        fingerDialog.setCallBackListener(this::fingerBack);
    }

    @Override
    public void fingerBack(boolean FingerCorrect) {
        if (FingerCorrect) {
            AppSettingHelper.setFingerIsOpen(true);
            setResult(RESULT_OK);
            finish();
        }
    }
}
